package cn.mw.cmdb.enums;

import java.util.ArrayList;
import java.util.List;

public enum RelatedSelectEnum {

    userNames("userNames", "users"),
    groupNames("groupNames", "groups"),
    orgNames("orgNames", "orgs"),
    pollingEngineName("pollingEngineName", "mw_pollingEngine"),
    monitorServerName("monitorServerName", "mw_monitorServerId");

    private String filedId;
    private String filedName;

    RelatedSelectEnum(String filedName, String filedId) {
        this.filedId = filedId;
        this.filedName = filedName;
    }

    public String getFiledId() {
        return filedId;
    }

    public void setFiledId(String filedId) {
        this.filedId = filedId;
    }

    public String getFiledName() {
        return filedName;
    }

    public void setFiledName(String filedName) {
        this.filedName = filedName;
    }

    public static RelatedSelectEnum getRelatedFieldInfo(String filedName) {
        for (RelatedSelectEnum r : RelatedSelectEnum.values()) {
            if (r.getFiledName().equals(filedName)) {
                return r;
            }
        }
        return null;
    }

    public static String getRelatedFieldIdByName(String filedName) {
        for (RelatedSelectEnum r : RelatedSelectEnum.values()) {
            if (r.getFiledName().equals(filedName)) {
                return r.getFiledId();
            }
        }
        return "";
    }

    public static List<String> getAllRelatedFieldName() {
        List<String> fieldNames = new ArrayList<>();
        for (RelatedSelectEnum r : RelatedSelectEnum.values()) {
            fieldNames.add(r.getFiledName());
        }
        return fieldNames;
    }

}
